package com.springbootdemo.shixundemo.Controller;

import jakarta.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @BelongsProject: ShiXunDemo
 * @BelongsPackage: com.springbootdemo.shixundemo.Controller
 * @Author: YoungDra
 * @CreateTime: 2024/07/08  20:49
 */
@Controller
public class newController {
    @GetMapping("/index")
    public String c(){
        return "index";
    }
    @GetMapping("/cc")
    public String d(String username, Model model){
        model.addAttribute("username",username);
        System.out.println(username);

        return "cc";
    }
    @GetMapping("/to/{str}")
    public String to(@PathVariable("str") String str){
        return str;
    }
@GetMapping("/login")
public String login(){
    return "login";
}
    @GetMapping("/check")
    public String check(String QQ,String code, HttpServletRequest request){
        String s= (String) request.getSession().getAttribute("validcode");
        System.out.println("qian:"+code);
        System.out.println("hou:"+s);
        if (code.equals(s))
            return "index";
        else
            return "login";
    }
}
